#include "SecondPulseSimul.h"

#include "Parameters.h"

#include "TrajSimul.h"
#include "PulseDelaySave.h"
#include "InitialPosition.h"

SecondPulseSimul::SecondPulseSimul()
{

}

SecondPulseSimul::~SecondPulseSimul()
{

}

MultiLayer SecondPulseSimul::solve(Clock clock,Output output,Pulse *field,Pulse *current,MultiLayer multiLayer,NewParameters params)
{

  MultiLayer result=multiLayer;
  output.setSave(false);
  int layerNumber=multiLayer.getSolveLayer();
  multiLayer[layerNumber].setMag(InitialPosition(clock,output,field,current,multiLayer,params)); 
  for(current->setSecondPulse(params.getDoublePulse()["secondMind"]);current->getSecondPulse()<params.getDoublePulse()["secondMax"];current->setSecondPulse(current->getSecondPulse()+params.getDoublePulse()["secondStep"]))
    {
      output.setSave(false);
      result=TrajSimul().solve(clock,output,field,current,multiLayer,params);
      PulseDelaySave().save(output,current,result);
    }
  return multiLayer;
}
